package com.hanhanxiaochong.zhongxiangchuanmei.presenter.my;

import com.hanhanxiaochong.zhongxiangchuanmei.bean.DealDetailBean;
import com.hanhanxiaochong.zhongxiangchuanmei.config.HttpPostService;
import com.hanhanxiaochong.zhongxiangchuanmei.presenter.base.BasePresenter;
import com.hanhanxiaochong.zhongxiangchuanmei.view.iview.IDealDetailView;
import com.trello.rxlifecycle.components.support.RxAppCompatActivity;
import com.wzgiceman.rxretrofitlibrary.retrofit_rx.Api.BaseApi;
import com.wzgiceman.rxretrofitlibrary.retrofit_rx.Api.BaseObserver;
import com.wzgiceman.rxretrofitlibrary.retrofit_rx.Api.ResponseBase;
import com.wzgiceman.rxretrofitlibrary.retrofit_rx.http.RetrofitSource;

import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Author : 贾桐
 * E-mail : 653773284@qq.com
 * Time   : 2018/6/11.
 * Desc   :
 */

public class DealDetailPresenter extends BasePresenter<IDealDetailView> {

    public DealDetailPresenter(IDealDetailView iView) {
        super(iView);
    }

    public void getUserDetail(String token, String id){
        addSubscription(RetrofitSource.createApi(HttpPostService.class).getUserRewardDetail(token, id)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseObserver<ResponseBase<DealDetailBean>>(iView) {
                    @Override
                    public void onSuccess(ResponseBase<DealDetailBean> response) {
                        iView.getUserDealDetail(response.getData());
                    }
                })
        );
    }

    public void getStorDetail(String token, String id){
        addSubscription(RetrofitSource.createApi(HttpPostService.class).getStorRewardDetail(token, id)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseObserver<ResponseBase<DealDetailBean>>(iView) {
                    @Override
                    public void onSuccess(ResponseBase<DealDetailBean> response) {
                        iView.getStroDealDetail(response.getData());
                    }
                })
        );
    }

    @Override
    public void startPost(RxAppCompatActivity rxAppCompatActivity, BaseApi baseApi) {

    }

    @Override
    public void startPost(RxAppCompatActivity rxAppCompatActivity, BaseApi baseApi, int state) {

    }
}
